package com.topgay.dao;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.topgay.domain.ChattingMessage;

@Repository
public class ChattingDAO {

	@Autowired
	private SqlSessionTemplate session;
	
	public int insertMessage(ChattingMessage m_obj){
		return session.insert("chatting.insertMessage", m_obj);
	}
	
	public List<ChattingMessage> selectMessageById(String fromId){
		List<ChattingMessage> tmpList =  session.selectList("chatting.selectMessageById", fromId);
		
		session.delete("deleteMessage", fromId);
		
		return tmpList;
	}
	
	public ChattingMessage selectMessageByNum(int rowNum){
		return session.selectOne("chatting.selectMessageByNum", rowNum);
	}
	
	public List<ChattingMessage> selectAllMessage(){
		return session.selectList("chatting.selectAllMessage");
	}
}
